package com.powergisol.gis.service.impl;

import com.powergisol.gis.dao.TabModelMapper;
import com.powergisol.gis.entity.TabModel;
import com.powergisol.gis.service.TabModelService;
import com.powergisol.gis.util.Result;
import com.powergisol.gis.vo.TabModelVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created By marc
 * Date: 2020/11/17  11:43
 * Description:
 */
@Service
public class TabModelServiceImpl implements TabModelService {

    @Autowired
    private TabModelMapper tabModelMapper;

    @Override
    public Result insertSelective(TabModel record) {
        Result r = new Result();
        record.setCreateTime(new Date());
        tabModelMapper.insertSelective(record);
        r.setData(record);
        return r;
    }

    @Override
    public Result selectByCondition(Integer sceneId, String serviceName) {
        Result r = new Result();
        TabModelVo tab = tabModelMapper.selectByCondition(sceneId, serviceName);
        r.setData(tab);
        return r;
    }

    @Override
    public Result delModel(Integer sceneId, String serviceName) {
        Result r = new Result();
        tabModelMapper.delModel(sceneId, serviceName);
        return r;
    }

    @Override
    public Result updateTabModel(TabModel record) {
        Result r = new Result();
        record.setUpTime(new Date());
        tabModelMapper.updateTabModel(record);
        return r;
    }

    @Override
    public Result getStatic(Integer staticNum) {
        Result r = new Result();
        List<Map<String,Object>> list = tabModelMapper.getStatic(staticNum);
        r.setData(list);
        return r;
    }
}
